package com.jiutong.meipenggang.http.present;

import android.content.Context;

import com.jiutong.meipenggang.entity.RepaymentPlanBean;
import com.jiutong.meipenggang.http.model.interfaces.RepaymentPlanBiz;
import com.jiutong.meipenggang.http.model.requests.MeiLiCaiFragmentRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/19 10:57
 * @describe
 */

public class RepaymentPlanPresent {

    private Context mContext;
    private MeiLiCaiFragmentRequest meiLiCaiFragmentRequest;
    private RepaymentPlanBiz repaymentPlanBiz;

    public RepaymentPlanPresent(Context mContext, RepaymentPlanBiz repaymentPlanBiz) {
        this.mContext = mContext;
        this.repaymentPlanBiz = repaymentPlanBiz;
        meiLiCaiFragmentRequest = new MeiLiCaiFragmentRequest();
    }

    /**
     * 获取还款计划信息
     */
    public void getRepaymentPlanInfo(){
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<RepaymentPlanBean>() {
            @Override
            public void onNext(RepaymentPlanBean object) {
                repaymentPlanBiz.onSuccess(object);
            }

            @Override
            public void onError(Throwable e) {
                repaymentPlanBiz.onError(e);
            }
        };
        HashMap<String,Object> fieldMap = new HashMap<>();
        fieldMap.put("OPT",repaymentPlanBiz.getOpt());
        fieldMap.put("bidId",repaymentPlanBiz.bidId());
        meiLiCaiFragmentRequest.getRepaymentPlanInfo(new ProgressSubscriber(onNextListener,mContext),fieldMap);
    }
}
